<?php

namespace services\models;

/**
 * This is the ActiveQuery class for [[\common\models\SpecType]].
 *
 * @see \common\models\SpecType
 */
class SpecTypeQuery extends \common\models\SpecType
{
    public static function getDb() {
        return \Yii::$app->db;
    }
    
    public static function getSpecOrder($array) {
        if(!empty($array[1]['id'])) {
            $vars = self::find()->where('(spec_id = :spec_id OR spec_id = :spec_id1) AND type_id = :type_id',[':spec_id'=>$array[0]['id'],':spec_id1'=>$array[1]['id'],':type_id'=>$array[0]['type_id']])->orderBy('train ASC , uid ASC')->all();
        } else {
            $vars = self::find()->where('(spec_id = :spec_id) AND type_id = :type_id',[':spec_id'=>$array[0]['id'],':type_id'=>$array[0]['type_id']])->orderBy('train ASC , uid ASC')->all();
        }
        
        return \yii\helpers\ArrayHelper::toArray($vars);
    }
}
